#include "mainwindow.h"

#include <QApplication>

#include "ElaApplication.h"

#include "logindialog.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    eApp->init();   // 初始化单例


    MainWindow w;
// w.show();
    LoginDialog login;

    // QObject::connect(&w, &MainWindow::windowShown, &login, &LoginDialog::close);
    QObject::connect(&w, &MainWindow::windowShown, &login, [&login, &w](){
        QObject::disconnect(&login, &LoginDialog::rejected, &w, &MainWindow::onLoginCanceled);
        login.close();  // 关闭登录窗口
    });
    QObject::connect(&login, &LoginDialog::accepted, &w, &MainWindow::onLoginSuccess);
    QObject::connect(&login, &LoginDialog::rejected, &w, &MainWindow::onLoginCanceled);

    login.show();  // 非阻塞显示



    return a.exec();
}
